package com.example.community.uitls;

import com.example.community.dao.pojo.User;
import org.springframework.stereotype.Component;

/**
 * @ClassName: HostHolder
 * @Description:
 * @Author
 * @Date 2022-03-18
 * @Version 1.0
 */
@Component
public class HostHolder {

    private ThreadLocal<User> users = new ThreadLocal<>();

    public void setUser(User user){
        users.set(user);
    }

    public User getUser(){
        return users.get();
    }

    public void clear(){
        users.remove();
    }
}
